<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<link href="tp/favico.ico" rel="shortcut icon" />
	<link href="css/m_member.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery-3.1.0.js"></script>
<script type="text/javascript">
	$(function(){
		$(".def").click(function(){
			var a = $(this);
			var aid = a.attr("aid");
			$.get("SetDefault", {aid: aid}, function(){
				//相当于打开：SetDefaultServlet?aid=aid
				location.reload();//刷新页面
				//a.remove();
			});
		});
	});
	function dz(id){
		var x=confirm("您确定要删除此地址吗？");
		if(x==true){
			$.get("AddressServlet", {id: id,}, function(){
				 alert("地址删除成功！");
				 location.reload();//刷新页面
			 });	
		}
	}
</script>
<title>我的收货地址</title>
</head>
<body 	style="overflow-x: hidden;">
<div class="m4">
		<div class="m5">
			<h5 class="m7">
				<span>收货人信息</span>
			</h5>
	<div>
		<div id="main_right">
			<div>
				<div class="btn_area">
					<a class="a-btn" href="m_address.jsp?id=${param.id}">新增地址</a>
				</div>
				<table class="tab_list">
					<tr>
						<th>收货人</th>
						<th>电话</th>
						<th>收货地址</th>
						<th>邮编</th>
						<th>操作</th>
					</tr>
					
					<c:forEach items="${list}" var="a">
						<tr>
							<td>${a.addressName}</td>
							<td>${a.addressPhone }</td>
							<td>${a.addressDetails }</td>
							<td>${a.addressemail }</td>
							<td>
								<c:if test="${not a.addressState}">
									<a class="def" aid="${a.addressId}" href="javascript:void(0)">设为默认</a>
								</c:if>
								<a href="UpaddressServlet?id=${a.addressId }">修改</a>
								<a onclick="dz(${a.addressId})" Style="cursor: pointer;">删除</a>
							</td>
						</tr>
					</c:forEach>
				</table>
			</div>
		</div>
	</div>
	</div>
	</div>
</body>
</html>